﻿<Window x:Class="Woodstock.Quad.TestApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:src="clr-namespace:Woodstock.Quad.TestApp" 
        Title="MainWindow" Height="768 " Width="1024" Loaded="Window_Loaded" KeyDown="Window_KeyDown" Closing="Window_Closing" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">

    <Window.Resources>
        <src:TeapotMesh x:Key="teapot" />
    </Window.Resources>

    
    <Grid>
        <Grid Height="137" HorizontalAlignment="Left" Margin="18,12,0,0" Name="grid1" VerticalAlignment="Top" Width="333">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <TextBlock Text="Motor 1" HorizontalAlignment="Center" VerticalAlignment="Center" />
            <TextBox Name="textBoxSpeedMotor1" VerticalAlignment="Center" Grid.Column="1" />

            <TextBlock Text="Motor 2" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" />
            <TextBox Name="textBoxSpeedMotor2" VerticalAlignment="Center" Grid.Row="1" Grid.Column="1" />

            <TextBlock Text="Motor 3" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="2" />
            <TextBox Name="textBoxSpeedMotor3" VerticalAlignment="Center" Grid.Row="2" Grid.Column="1" />

            <TextBlock Text="Motor 4" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="3" />
            <TextBox Name="textBoxSpeedMotor4" VerticalAlignment="Center" Grid.Row="3" Grid.Column="1" />
        </Grid>
        
        <Grid Height="137" HorizontalAlignment="Right" Margin="0,155,651,0" Name="grid2" VerticalAlignment="Top" Width="333">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <TextBlock HorizontalAlignment="Center" Text="Global Speed" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Name="textBoxGlobalSpeed" VerticalAlignment="Center" />

            <TextBlock HorizontalAlignment="Center" Text="Motors Plugged In" VerticalAlignment="Center" Grid.Row="1" Foreground="Red" FontWeight="Bold" Name="textBlockMotorsAttached" Visibility="Collapsed" />
        </Grid>
        <Button Content="Turn On" Height="23" HorizontalAlignment="Left" Margin="367,14,0,0" Name="buttonTurnOn" VerticalAlignment="Top" Width="75" Click="buttonTurnOn_Click" />
        
        
        
        


        <ListView Height="215" HorizontalAlignment="Left" Margin="629,21,0,0" Name="listViewStateHistory" VerticalAlignment="Top" Width="325">
            <ListView.View>
                <GridView AllowsColumnReorder="true" ColumnHeaderToolTip="X">
                    <GridViewColumn DisplayMemberBinding="{Binding Path=XAcceleration}"  Header="X" Width="100"/>                    
                </GridView>

            </ListView.View>

        </ListView>

        <Grid Height="151" Margin="415,292,0,0" Name="gridHorizon" VerticalAlignment="Top" Width="223" HorizontalAlignment="Left"></Grid>

        <Canvas Width="321" Height="201" Margin="657,275,23,253">

            <!-- The Viewport3D provides a rendering surface for 3-D visual content. -->
            <Viewport3D Name="MyAnimatedObject" ClipToBounds="True" Width="320" Height="201">

                <!-- Defines the camera used to view the 3D object. -->
                <Viewport3D.Camera>
                    <PerspectiveCamera x:Name="myPerspectiveCamera" Position="0,0,4" LookDirection="0,0,-1" FieldOfView="60" />
                </Viewport3D.Camera>

                <!-- The ModelVisual3D children contain the 3D models -->
                <Viewport3D.Children>

                    <!-- Two ModelVisual3D define the lights cast in the scene. Without light, the
                 3D object cannot be seen. Also, the direction of the lights affect shadowing. -->
                    <ModelVisual3D>
                        <ModelVisual3D.Content>
                            <DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
                        </ModelVisual3D.Content>
                    </ModelVisual3D>
                    <ModelVisual3D>
                        <ModelVisual3D.Content>
                            <DirectionalLight Color="#FFFFFF" Direction="0.612372,-0.5,-0.612372" />
                        </ModelVisual3D.Content>
                    </ModelVisual3D>
                    
                    <ModelVisual3D>
                        <ModelVisual3D.Content>
                            <GeometryModel3D Geometry="{Binding Source={StaticResource teapot}, Path=Geometry}">

                                <!-- The material specifies the material applied to the plane. In this case it is a linear gradient.-->
                                <GeometryModel3D.Material>
                                    <MaterialGroup>
                                        <DiffuseMaterial>
                                            <DiffuseMaterial.Brush>
                                                <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                                                    <LinearGradientBrush.GradientStops>
                                                        <GradientStop Color="Yellow" Offset="0" />
                                                        <GradientStop Color="Red" Offset="0.25" />
                                                        <GradientStop Color="Blue" Offset="0.75" />
                                                        <GradientStop Color="LimeGreen" Offset="1" />
                                                    </LinearGradientBrush.GradientStops>
                                                </LinearGradientBrush>
                                            </DiffuseMaterial.Brush>
                                        </DiffuseMaterial>
                                    </MaterialGroup>
                                </GeometryModel3D.Material>

                                <!-- The Transform specifies how to transform the 3D object. The properties of the
                                Rotation object are animated causing the 3D object to rotate and "wobble" (see Storyboard below).-->
                                <GeometryModel3D.Transform>
                                    <Transform3DGroup>

                                        

                                        <RotateTransform3D>
                                            <RotateTransform3D.Rotation>
                                                <!--<AxisAngleRotation3D x:Name="RollAngleRotation" Axis="1,0,0" Angle="45" />-->
                                                <QuaternionRotation3D x:Name="quartenion3d" >
                                                </QuaternionRotation3D>
                                            </RotateTransform3D.Rotation>                                        
                                        </RotateTransform3D>

                                        <RotateTransform3D>
                                            <RotateTransform3D.Rotation>
                                                <AxisAngleRotation3D x:Name="YawAngleRotation" Axis="0,1,0" Angle="0" />
                                            </RotateTransform3D.Rotation>
                                        </RotateTransform3D>

                                        <RotateTransform3D>
                                            <RotateTransform3D.Rotation>
                                                <AxisAngleRotation3D x:Name="PitchAngleRotation" Axis="0,0,1" Angle="0" />
                                            </RotateTransform3D.Rotation>
                                        </RotateTransform3D>
                                    </Transform3DGroup>
                                </GeometryModel3D.Transform>
                            </GeometryModel3D>
                        </ModelVisual3D.Content>
                    </ModelVisual3D>
                </Viewport3D.Children>

                <!-- Trigger the rotation animation when the 3D object loads. -->
                <!--<Viewport3D.Triggers>
                    <EventTrigger RoutedEvent="Viewport3D.Loaded">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation 
                   Storyboard.TargetName="myAngleRotation" 
                   Storyboard.TargetProperty="Angle" 
                   From="-60" To="60" Duration="0:0:4" AutoReverse="True"  RepeatBehavior="Forever"/>

                                <Vector3DAnimation 
                   Storyboard.TargetName="myAngleRotation" 
                   Storyboard.TargetProperty="Axis" 
                   From="0,3,0" To="1,0,1" Duration="0:0:4" AutoReverse="True"  RepeatBehavior="Forever"/>

                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Viewport3D.Triggers>-->
                
            </Viewport3D>
        </Canvas>





        <Grid Height="100" HorizontalAlignment="Left" Margin="18,306,0,0" Name="grid3" VerticalAlignment="Top" Width="333">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <TextBlock HorizontalAlignment="Center" Text="Gyro X" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Name="textBoxGyroX" VerticalAlignment="Center" />
            <TextBlock Grid.Row="1" HorizontalAlignment="Center" Text="Gyro Y" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="1" Name="textBoxGyroY" VerticalAlignment="Center" />
            <TextBlock Grid.Row="2" HorizontalAlignment="Center" Text="Gyro Z" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="2" Name="textBoxGyroZ" VerticalAlignment="Center" />
        </Grid>
        <Grid Height="100" HorizontalAlignment="Left" Margin="18,415,0,0" Name="grid4" VerticalAlignment="Top" Width="333">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <TextBlock HorizontalAlignment="Center" Text="Acel X" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Name="textBoxAcelX" VerticalAlignment="Center" />
            <TextBlock Grid.Row="1" HorizontalAlignment="Center" Text="Acel Y" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="1" Name="textBoxAcelY" VerticalAlignment="Center" />
            <TextBlock Grid.Row="2" HorizontalAlignment="Center" Text="Acel Z" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Grid.Row="2" Name="textBoxAcelZ" VerticalAlignment="Center" />
        </Grid>
        
        <telerik:RadChart Height="181" HorizontalAlignment="Left" Margin="18,521,0,0" Name="radChartAngles" VerticalAlignment="Top" Width="948">            
        </telerik:RadChart>
    </Grid>
</Window>
